from flask import Blueprint,jsonify,json
from flask_restful import request,reqparse
from db import db

from utils.my_redis import r

user_db=Blueprint('user_db',__name__)

# 对数据进行更新
@user_db.route('/shopping',methods=["POST"])
def shopping():
    if request.method=="POST":
        req=reqparse.RequestParser()
        req.add_argument('id')
        req.add_argument('sid')
        req.add_argument('cid')
        req.add_argument('create_time')
        args=req.parse_args()
        sql="select id from staff where id=%d"%(int(args['id']))
        res=db.find(sql)
        if int(res['id'])==3:
            sql1="update orders set sid=1 and cid=1 where "
            # sql1="insert into orders(sid,cid) values(%d,%d)"%(int(args['sid']),int(args['cid']))
            db.update(sql1)
            # sql2 = "insert into consignee(create_time) values('%s')" % (args['create_time'])
            sql2="update consignee set create_time= where "
            db.update(sql2)
            db.commit()
            return jsonify({'code':200,'msg':'管理员用户购买成功'})
        return jsonify({
            'code':400,
            'msg':'没有管理员'
        })








